package com.jiazhong.集合类.Test;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
import java.util.TreeSet;

public class Test07 {
    public static void main(String[] args) {
        //lnkedListDemo();
        //treeSetDemo();
        hashMapDemo();
    }
    
    public static void linkedListDemo(){
        LinkedList<Book> list=new LinkedList<>();
        for (int i = 1; i <=100 ; i++) {
            Book book=new Book(i,"name"+i,10+i);
            list.add(book);
        }
        for (Book book:list
             ) {
            System.out.println(book);
        }
    }

    public static void treeSetDemo(){
        TreeSet<Book> treeSet=new TreeSet<>();
        for (int i = 0; i < 100; i++) {
            Book book = new Book(i+1,"name"+i,10+i);

            treeSet.add(book);
        }


        for (Book book:treeSet
        ) {
            System.out.println(book);

        }
    }

    public static void hashMapDemo(){
        HashMap<Integer,Book> map=new HashMap<>();
        for (int i = 1; i <=100; i++) {
            Book book=new Book(i,"name"+i,10+i);
            map.put(book.getBookId(),book);
        }
        for (Map.Entry<Integer,Book> entry:map.entrySet()){
            System.out.println(entry.getKey()+":"+entry.getValue().getBookName());
        }
    }
}
